package com.demo.sort;

/**
 * @Description: 冒泡排序
 * @Author: xiangty
 * @Date: 2018-08-02
 */
public class BubbleSort {

    public static void main(String[] args) {
        int[] arr = {6, 3, 8, 2, 9, 1, 10};
        bubbleSort(arr);
        for (int i : arr) {
            System.out.print(i + "\t");
        }
    }

    public static void bubbleSort(int[] param) {
        int length = param.length;
        for (int i = length - 1; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                if (param[j] > param[j + 1]) {
                    int temp = param[j];
                    param[j] = param[j + 1];
                    param[j + 1] = temp;
                }
            }
        }
    }

}
